package com.gwq.interceptor;

import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.extern.log4j.Log4j2;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 * @version 1.0
 * @description TODO
 * @date 2024/7/25 15:21
 */

@Log4j2
@Aspect
@Component
public class DataSourceInterceptor {

    @Around(value = "@annotation(ds)")
    public Object dataSourceAop(ProceedingJoinPoint proceedingJoinPoint, DS ds) throws Throwable {
        log.info("找到数据源注解:[{}]", ds.value());
        log.info("<==========================");
        Object proceed = proceedingJoinPoint.proceed();
        log.info("==========================>");
        return proceed;
    }
}
